//base
import Taro, { Component } from '@tarojs/taro'
import { View, Text, Input } from '@tarojs/components'
//less
import './index.less'
import If from '../../../../../components/page-components/if'

class LocationSearch extends Component {
  componentWillMount() {
    //onLoad
  }

  componentDidMount() {
    //onready
  }

  componentWillUnmount() {
    //onUnload
  }

  componentWillReceiveProps(nextprops) {}

  delay(time = 0) {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve()
      }, time)
    })
  }

  timer = null

  onInput = e => {
    clearTimeout(this.timer)
    const value = e.detail.value
    this.timer = setTimeout(() => {
      this.props.onSearch({ value })
    }, 100)
  }

  render() {
    const { landmarkName } = this.props

    return (
      <View className="LocationSearch_id52301">
        <If visible={landmarkName}>
          <View className="ld-name">{landmarkName}</View>
        </If>
        <View className="search-wrap">
          <Input className="input-wrap" onInput={this.onInput} />
          <Image
            className="abs-img"
            mode="widthFix"
            src="https://imagesize.hrwork.com/sp/files/137bcff2-be12-4f9f-8548-a8ab49a35bc8.png"
          />
        </View>
      </View>
    )
  }
}

LocationSearch.defaultProps = {
  landmarkName: ''
}
export default LocationSearch
